package elasticsearch

import (
	"class_rpc/appconfig"
	"context"
	"fmt"
	"github.com/olivere/elastic/v7"
)

var (
	esClient *elastic.Client
	err      error
	ctx      context.Context
)

func InitEs() {
	a := appconfig.AppConf.EsConfig
	setUrl := fmt.Sprintf("http://%s:%s", a.Host, a.Port)
	esClient, err = elastic.NewClient(
		elastic.SetURL(setUrl),
		elastic.SetSniff(false),
	)
	if err != nil {
		// Handle error
		panic(err)
	}
	ctx = context.Background()
}
